package com.dbs.donatebooksystem.mapper;

import com.dbs.donatebooksystem.pojo.Orders;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper {
    @Select("select * from `orders`")
    List<Orders> selectOrder();


    @Insert("insert into `orders`(address_id,book_id,user_id,receiver_name,receiver_phone,create_time,status,order_number) " +
            "values (#{orders.addressId},#{orders.bookId},#{orders.userId},#{orders.receiverName},#{orders.receiverPhone},#{orders.createTime},#{orders.status},#{orders.orderNumber})")
    void insertOrders(@Param("orders") Orders orders);

    @Delete("delete from `orders` where order_id=#{orderId}")
    void deleteOrderById(@Param("orderId") Integer orderId);

    @Select("select * from `orders` where user_id = #{userId}")
    List<Orders> selectOrderByUserId(@Param("userId") Integer userId);

    @Select("select * from `orders` where order_id = #{orderId}")
    Orders getById(@Param("orderId") Integer orderId);

    @Update("update `orders` SET status=#{newStatus} where order_id = #{orderId}")
    void updateOrderStatus(@Param("orderId") Integer orderId,@Param("newStatus") Integer newStatus);

    List<Orders> conditionSelect(@Param("orders")Orders orders);


//    @Insert("insert into `order`")
//    void insertOrder();
}
